

import docutils.core

def HTMLToHTML(input):
    return input

def rSTToHTML(input):
    parts = docutils.core.publish_parts(
        input,
        source_path='inline',
        destination_path=None,
        writer_name='html',
        settings_overrides={'initial_header_level':'2'})
    return parts['fragment']
    

def ToHTML(input):
    if not input or len(input) == 0:
        return ''
    if input[:6].lower() == "!html!":
        return HTMLToHTML(input[6:])
    elif input[:5] == '!rST!':
        return rSTToHTML(input[5:])
    return rSTToHTML(input)



__all__ = ['ToHTML']
